package org.grottarossa.test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

import org.grottarossa.domain.CaseFolder;
import org.grottarossa.domain.Field;
import org.grottarossa.domain.Record;
import org.grottarossa.domain.Task;

public class DataGenerator  
{
	
	public static HashSet<Task> tasksGenerator(int numTasks)
	{
		return null;
	}
	 
	
	public HashSet<Field> fieldGenerator(int numFileds) {
		HashSet<Field> fields = new HashSet<Field>(numFileds);
		for (int i = 0; i < numFileds; i++) {
			Field f = new Field();
			f.setDescription("Description_" + i);
			f.setName("Name" + i);
			ArrayList<Object> vals = new ArrayList<Object>();
			vals.add("Valore Del Campo");
			f.setValue(vals);
			fields.add(f);
		}
		return fields;
	}
	
	public Collection<Record> generateRecord(int numRecord)
	{
		HashSet<Record> records = new HashSet<Record>();
		for(int i=0;i<numRecord;i++)
		{
			Record record = new Record();
			
			record.setFields(fieldGenerator( (2 + (int)(Math.random()*35)) ) );	//generate field from 2 to 35		
			record.setField("id", "1009");
			records.add(record);
		}
		return records;
		
	}
	
	public CaseFolder caseGenerator() 
	{
		CaseFolder caseF = new CaseFolder();
		caseF.setDescription("Descrizione casefolder");
		caseF.setName("Nome casefolder");
		caseF.setId("1004");
		
		Record rec = generateRecord(1).iterator().next();
		rec.setId("1109");
		caseF.setRecord( rec );
		return caseF;
	}

	

}
